<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<div class="container-fluid am-margin-top">
    <form id="dataDicItemForm">
        <input type="hidden" name="id"/>
        <input type="hidden" name="pid"/>
        <input type="hidden" name="dataDicId"/>
        <input type="hidden" name="dataDicCode"/>
        <div class="form-group">
            <label for="name">名称</label>
            <input type="text" name="name" class="form-control" check-type="required">
        </div>
        <div class="form-group">
            <label for="code">编码</label>
            <input type="text" name="code" class="form-control" check-type="required">
        </div>
        <div class="form-group">
            <label for="value">值</label>
            <input type="text" name="value" class="form-control" check-type="required">
        </div>

        <div class="form-group">
            <a href="javascript:void(0)" id="dataDicItemSaveBt"  class="btn btn-primary pull-right">保存</a>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var dataDicItemForm = $("#dataDicItemForm");
        var pid = '${param.pid}';
        var id = '${param.id}';
        var dataDicId = '${param.dataDicId}';
        var dataDicCode = '${param.dataDicCode}';
        dataDicItemForm.validation();
        dataDicItemForm.find("input[name=pid]").val(pid);
        dataDicItemForm.find("input[name=dataDicId]").val(dataDicId);
        dataDicItemForm.find("input[name=dataDicCode]").val(dataDicCode);


        if (id) {
            $.getJSON(ctx + '/dataDicAction/findDataDicItemById.do', {id: id}, function (data) {
                webUtils.fullForm({
                    form: dataDicItemForm,
                    data: data
                });
            });
        }
        $("#dataDicItemSaveBt").click(function () {
        	if(dataDicItemForm.valid()){
        		dataDicItemForm.ajaxSubmit({
                    url: ctx + '/dataDicAction/saveDataDicItem.do',
                    data: {},
                    type: "POST",
                    success: function (data) {
                        if (data.success) {
                            webUtils.alert("提交成功");
                            top.webUtils.topicPublish("dataDicAttr.edit.success", data);
                        } else {
                        	webUtils.error(data.msg);
                        }
                    }
                });
        	}
        });
    });
</script>